'
' *  Authors:  Benton Stark
' * 
' *  Copyright (c) 2007-2012 Starksoft, LLC (http://www.starksoft.com) 
' *
' * Permission is hereby granted, free of charge, to any person obtaining a copy
' * of this software and associated documentation files (the "Software"), to deal
' * in the Software without restriction, including without limitation the rights
' * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
' * copies of the Software, and to permit persons to whom the Software is
' * furnished to do so, subject to the following conditions:
' * 
' * The above copyright notice and this permission notice shall be included in
' * all copies or substantial portions of the Software.
' * 
' * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
' * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
' * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
' * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
' * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
' * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
' * THE SOFTWARE.
' * 
' 


Imports System.Security.Cryptography.X509Certificates
Imports System.Net.Security

Namespace FTP
    ''' <summary>
    ''' Event arguments to facilitate the FtpClient transfer progress and complete events.
    ''' </summary>
    Public Class ValidateServerCertificateEventArgs
        Inherits EventArgs

        Private _certificate As X509Certificate2
        Private _chain As X509Chain
        Private _policyErrors As SslPolicyErrors
        Private _isCertificateValid As Boolean

        ''' <summary>
        ''' ValidateServerCertificateEventArgs constructor.
        ''' </summary>
        ''' <param name="certificate">X.509 certificate object.</param>
        ''' <param name="chain">X.509 certificate chain.</param>
        ''' <param name="policyErrors">SSL policy errors.</param>
        Public Sub New(certificate As X509Certificate2, chain As X509Chain, policyErrors As SslPolicyErrors)
            _certificate = certificate
            _chain = chain
            _policyErrors = policyErrors
        End Sub

        ''' <summary>
        ''' The X.509 version 3 server certificate.
        ''' </summary>
        Public ReadOnly Property Certificate() As X509Certificate2
            Get
                Return _certificate
            End Get
        End Property

        ''' <summary>
        ''' Server chain building engine for server certificate.
        ''' </summary>
        Public ReadOnly Property Chain() As X509Chain
            Get
                Return _chain
            End Get
        End Property

        ''' <summary>
        ''' Enumeration representing SSL (Secure Socket Layer) errors.
        ''' </summary>
        Public ReadOnly Property PolicyErrors() As SslPolicyErrors
            Get
                Return _policyErrors
            End Get
        End Property

        ''' <summary>
        ''' Boolean value indicating if the server certificate is valid and can
        ''' be accepted by the FtpClient object.
        ''' </summary>
        ''' <remarks>
        ''' Default value is false which results in certificate being rejected and the SSL
        ''' connection abandoned.  Set this value to true to accept the server certificate 
        ''' otherwise the SSL connection will be closed.
        ''' </remarks>
        Public Property IsCertificateValid() As Boolean
            Get
                Return _isCertificateValid
            End Get
            Set(value As Boolean)
                _isCertificateValid = value
            End Set
        End Property
    End Class
End Namespace
